package com.lyluly.coursemgmt.servicemodule.iService.serviceImpl;

import com.lyluly.coursemgmt.servicemodule.iDao.LessonMapper;
import com.lyluly.coursemgmt.servicemodule.iService.ILessonService;
import com.lyluly.coursemgmt.servicemodule.model.Lesson;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class LessonServiceImpl implements ILessonService {
    @Autowired
    private LessonMapper lessonMapper;

    public void addLesson(Lesson lesson) {
        lesson.setCreatetime(new Date());
        lessonMapper.insert(lesson);
    }

    public void modifyLesson(Lesson lesson) {
        lessonMapper.updateByPrimaryKeySelective(lesson);
    }

    public void removeLesson(int lessonId) {
        lessonMapper.deleteByPrimaryKey(lessonId);
    }

    public Lesson findLessonById(int lessonId) {
        return lessonMapper.selectByPrimaryKey(lessonId);
    }

    public List<Lesson> findLessonList() {
        return lessonMapper.selectByExample(null);
    }
}
